api.js ➔ ???   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1.729

Importance

Changes 0
Metric Value
cc 1
nc 1
dl 0
loc 25
ccs 1
cts 10
cp 0.1
crap 1.729
rs 8.8571
c 0
b 0
f 0
nop 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A api.js ➔ ... ➔ ??? 0 1 1
1
"use strict";
2
3 1
exports.getInformation = (postId) => {
4
    return fetch('http://localhost:3000/posts/' + postId)
5
        .then((response) => response.json())
6
        .then((responseJson) => {
7
            let jsonInfo = responseJson.json;
8
            let information;
9
10
            try {
11
                let info = {
12
                    title: jsonInfo.items[0].title,
13
                    link: jsonInfo.items[0].link
14
                };
15
16
                information = info;
17
            } catch (e) {
18
                console.error('\x1b[41m', 'Undefined map item', '\x1b[0m');
19
            }
20
            // console.log("outsude");
21
            // console.log(information);
22
            return information;
0 ignored issues
show
Bug introduced by
The variable information does not seem to be initialized in case let info = {IdentifierNo...ifierNode(link,false))} on line 11 throws an error. Are you sure this can never be the case?
Loading history...
23
        })
24
        .catch((error) => {
25
            console.error(error);
26
        });
27
};
28
29 1
exports.getUserInformation = (userId) => {
30
    return fetch('http://localhost:3000/users/' + userId)
31
        .then((response) => response.json())
32
        .then((responseJson) => {
33
            let jsonInfo = responseJson.json;
34
            let information;
35
36
            try {
37
                let info = {
38
                    name: jsonInfo.items[0].display_name,
39
                    link: jsonInfo.items[0].link
40
                };
41
42
                information = info;
43
            } catch (e) {
44
                console.error('\x1b[41m', 'Undefined map item', '\x1b[0m');
45
            }
46
47
            return information;
0 ignored issues
show
Bug introduced by
The variable information does not seem to be initialized in case let info = {IdentifierNo...ifierNode(link,false))} on line 37 throws an error. Are you sure this can never be the case?
Loading history...
48
        })
49
        .catch((error) => {
50
            console.error(error);
51
        });
52
};
53